
# ifndef __DFX_AUDIO_SOURCE_OAL_H__
# define __DFX_AUDIO_SOURCE_OAL_H__

# include "dfxAudioSource.h"
# include <al.h>
# include <alc.h>

namespace DFX
{
    const int BUFFER_SIZE = 2 * 262144;

    class AudioSource_OAL : public AudioSource
    {
    private:

        ALuint  mSourceID;
        ALuint  mBufferID[2];
        UInt32  mNumBuffers;
        bool    mLooping;

    public:

        AudioSource_OAL();
        ~AudioSource_OAL();

        bool IsPlaying() const;

        void Play();
        void Stop();
        void Pause();

        void LoopSound(bool loop);
        void SetVolume(Float32 volume);

        void Update(Float32 deltaSeconds);
        void BindWaveForm(WaveDataProvider *wave);        

        void UnqueueAll();

    private:

        ALint StreamBuffer(ALuint bufferId, ALint size);
    };
}

# endif